import React, { useEffect } from 'react'
import { useState } from 'react'
import { useLocation } from 'react-router-dom'
import {pageTitle} from '../../config'

const Header=(props)=>{
    // const {title='饿了吗'}= props

    // let title='elm'
    const [title,setTitle]=useState('首页')
    const {pathname='/'}= useLocation()
    useEffect(()=>{
        // const location =window.location.pathname
        let _title=pageTitle[pathname]||'';
        // if(pathname=='./order'){
        //     _title='订单页面'
        // }else if(pathname=='./home'||pathname=='./'){
        //     _title='首页'
        // }
        setTitle(_title)
        
    },[pathname])
    // console.log(title)
    return(
        <header>{title}</header>
    )
}

export default Header